import React from 'react'
import axios from 'axios'
import { Spin } from 'antd'

class Loading extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      spinning:false
    }
  }
  componentDidMount() {
    // 拦截请求
    axios.interceptors.request.use(function(config) {
      this.setState({spinning:true})
      return config
    })
    
    // 拦截响应
    axios.interceptors.response.use(function(config) {
      this.setState({spinning:false})
      return config
    })
  }
  render() {
    console.log(this.state.spinning)
    return <Spin spinning={true} delay={500}></Spin>
  }
}

export default Loading